package com.qingfeng.base.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qingfeng.base.dao.TRoleMapper;
import com.qingfeng.base.dao.TRoleMenuMapper;
import com.qingfeng.base.model.TRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author  zhangyuefei
 * @date  2019/9/11 10:34 上午
 * @version 1.0
 */
@Service
public class TRoleService extends ServiceImpl<TRoleMapper, TRole> {

    @Autowired
    private TRoleMenuMapper tRoleMenuMapper;


    public int addPermission(String roleId, List<String> permissions) {
        tRoleMenuMapper.deleteByRoleId(roleId);
        if (permissions==null || permissions.size()==0){
            return 1;
        }
       int index = tRoleMenuMapper.insertList(roleId,permissions);
       return index;
    }

    public void deleteList(List<String> idList) {
        baseMapper.deleteByIds(idList);
    }
}
